home *** CD-ROM | disk | FTP | other *** search
/ The X-Philes (2nd Revision) / The X-Philes Number 1 (1995).iso / xphiles / hp48_2 / scroll.men < prev    next >
Text File  |  1995-03-23  |  12KB  |  268 lines

  1. Article 1674 of comp.sys.handhelds:
  2. Path: en.ecn.purdue.edu!noose.ecn.purdue.edu!samsung!zaphod.mps.ohio-state.edu!mips!bridge2!jarthur!dwalton
  3. From: dwalton@jarthur.Claremont.EDU (Dave Walton)
  4. Newsgroups: comp.sys.handhelds
  5. Subject: Re: STRING->CODE in ASC Format
  6. Summary: Scrollable menu utility for HP48SX
  7. Keywords: MENU SCROLL
  8. Message-ID: <8917@jarthur.Claremont.EDU>
  9. Date: 7 Oct 90 00:30:09 GMT
  10. References: <8034@helios.TAMU.EDU>
  11. Organization: Harvey Mudd College, Claremont, CA 91711
  12. Lines: 252
  13.  
  14. Here's a program that creates a scrollable menu facility on the HP48SX.
  15. It's easy to edit, so can be taylored to many uses.  See the comments
  16. below for more info.
  17. There's also a demo file below the main program that shows how to use
  18. the SCRL program from inside another program (though it can be run
  19. standalone)
  20.  
  21. %%HP: T(3)A(R)F(.);
  22. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  23. @                                                                      @
  24. @  Name:        SCRL    (size 1951.5, checksum #17721d)                @
  25. @                                                                      @
  26. @  Description: This program is a scrollable menu program.  It can be  @
  27. @                 called externally from another program (see SCRL.DMO)@
  28. @                 or it can be made into a standalone program.  Right  @
  29. @                 now, the program is written for values of the form   @
  30. @                 :TAG:VALUE.  When the value is displayed on the lcd, @
  31. @                 only TAG:VALUE is displayed.  And when the value is  @
  32. @                 pushed onto the stack, the full :TAG:VALUE is pushed,@
  33. @                 but only TAG:VALUE shows up.  For example, if you    @
  34. @                 push :DEMOTAG:123 onto the stack, only DEMOTAG:123   @
  35. @                 shows up.  Then if you press '3 -' then the tag is   @
  36. @                 stripped off, and 120 is the result.  Play around    @
  37. @                 with it.  You'll get the idea.  Anyway, the program  @
  38. @                 can easily be modified to handle other types of data @
  39. @                 as I have indicated further on in the file.  Also,   @
  40. @                 I have defined the first function key as the 'push   @
  41. @                 to stack' key and the last function key as 'exit'.   @
  42. @                 It is pretty trivial to add different functions.     @
  43. @                 Just look below!  Well, that's about all.  I hope    @
  44. @                 this program is useful!  If you have any comments,   @
  45. @                 contact me at my net address below.                  @
  46. @                                                                      @
  47. @  Arguments:   NONE                                                   @
  48. @                                                                      @
  49. @  History:     01-OCT-90 -Dave Walton- Original coding.               @
  50. @                                                                      @
  51. @  Address:     dwalton@@jarthur.claremont.edu                         @
  52. @                  (use only one 'at')                                 @
  53. @                                                                      @
  54. @  About the author:  Dave Walton is a Junior at Havey Mudd College    @
  55. @                     and is pursuing a degree in general engineering. @
  56. @                                                                      @
  57. @  Payment:     If you like this program, send $80,000 to me to cover  @
  58. @                  my education!!!  No just kidding, but a nice mail   @
  59. @                  message would be appreciated!                       @
  60. @                                                                      @
  61. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  62. \<<
  63. @@@@@
  64. @ If you were going to make a standalone menu program, place the
  65. @ data HERE!!!!  Eg:
  66. @ { "TITLE" ":AAA:1" ":BBB:2:" ":CCC:3" }
  67. @@@@@
  68. 0 0 \->
  69. M                            @M --> Matrix containing all values (from stack)
  70. MAX                          @MAX --> Total number of values
  71. CURSOR                       @CURSOR --> Cursor grob
  72.   \<<
  73. ERASE                        @Erase graphics screen
  74. { # 0d # 0d } PVIEW          @Show graphics screen
  75. PICT { # 0d # 0d }           @Retrieve blank graphics screen to stack
  76. M LIST\-> 1 -                  @Break up M and reform without first entry
  77.   \->LIST 'M' STO              @     which is the title
  78.   M SIZE 'MAX' STO           @Save size of M
  79. "                       "    @Set up cursor grob
  80. 2 \->GROB NEG
  81. 'CURSOR' STO
  82. 2 \->GROB REPL                 @Title was on stack. Grob and put on screen
  83. { {"\->STK" } { "" } {         @Set up temporary function menu
  84. "" } { "" } { "" }
  85. { "EXIT" } } TMENU
  86. 1 1 9 9 0 \->
  87. CURR                         @CURR --> Current VALUE
  88. TOPR                         @TOPR --> VALUE currently at top position on lcd
  89. POSR                         @POSR --> Position of CURR
  90. TPOSR                        @TPOSR --> Temp position
  91. KEYPRESS                     @KEYPRESS --> Key pressed by user
  92.     \<<
  93.       DO                     @Only update screen of KEYPRESS = 0
  94.         IF '
  95. KEYPRESS==0'
  96.         THEN
  97. 9 'TPOSR' STO                @Start from position 9
  98. TOPR TOPR 4 +                @Print values from TOPR to TOPR+4
  99.           FOR I
  100. PICT # 0d TPOSR DUP          @Push screen grob to stack and form coordinate
  101. 9 + 54 MOD 'TPOSR'           @      list of where next value should go
  102. STO R\->B 2 \->LIST              @      Eg. { # 0d # 30d } will print at (0,30)
  103. M I GET                      @Get I'th VALUE
  104. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  105. DUP SIZE 2 SWAP              @Translate :TAG:VALUE to TAG:VALUE
  106. SUB                          @       Modify this for different types of VALUE
  107. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  108. 2 \->GROB REPL                 @Put VALUE on screen
  109.           NEXT
  110. PICT # 0d POSR R\->B 2         @Place CURSOR on current VALUE
  111. \->LIST CURSOR GXOR
  112.         END
  113. -1 WAIT                      @Wait for a key press
  114. FLOOR                        @Get integer part of value of key pressed
  115. 'KEYPRESS' STO               @           and store it in KEYPRESS
  116.         IF '                 @If key was 1st function key, push to stack
  117. KEYPRESS==11'
  118.         THEN M CURR GET      @Get current VALUE
  119. STR\->                         @Convert from string to value
  120.         END
  121. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  122. @The previous 'push to stack' could be modified for different types of
  123. @  data.  For example, if the user wanted the value of type string to
  124. @  be coppied exactly (and as a string) to the stack, the code would look
  125. @  like this:
  126. @  ... THEN M CURR GET END...
  127. @  Easy, huh?
  128. @Also, here is where the rest of the function key declarations would go
  129. @  where 12 --> function key 2,
  130. @        13 --> function key 3,  etc.
  131. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  132.         IF '                 @Up arrow
  133. KEYPRESS==25'
  134.         THEN PICT            @Push screen grob to stack
  135. # 0d POSR R\->B 2              @Make current position
  136. \->LIST CURSOR GXOR            @Turn off cursor
  137.           IF 'CURR           @If we're already at the first element,
  138. ==1'
  139.           THEN MAX           @         then print last screen and place
  140. 'CURR' STO MAX 4 -           @         cursor on last line.
  141. 'TOPR' STO 45
  142. 'POSR' STO 9
  143. 'TPOSR' STO 0                @Set KEYPRESS to 0 so that we go through the
  144. 'KEYPRESS' STO               @         first loop again and print all values.
  145.           ELSE CURR
  146. 1 - 'CURR' STO POSR          @If not at first value, decrement CURR and POSR
  147. 9 - 'POSR' STO
  148.             IF '             @If we're now above the first entry, shift the
  149. POSR==0'                     @         screen down
  150.             THEN
  151.               IF '
  152. TOPR\=/1'
  153.               THEN
  154. TOPR 1 - 'TOPR' STO          @Set new element for top of screen
  155. PICT { # 0d # 18d }          @Put position of where copied section WILL GO
  156. PICT { # 0d # 9d }           @Put position of where WILL COPY SECTION FROM
  157. { # 131d # 44d }             @Put bottom right corner of where WILL COPY FROM
  158. SUB                          @Move section
  159. PICT { # 0d                  @Now put new row that we don't have yet onto
  160. # 9d } M TOPR GET            @           screen
  161. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  162. DUP SIZE 2 SWAP SUB          @THIS LINE CONVERTS :TAG:VALUE to TAG:VALUE
  163. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  164. 2 \->GROB REPL REPL
  165.               END 9
  166. 'POSR' STO
  167.             END
  168. PICT # 0d POSR R\->B
  169. 2 \->LIST CURSOR GXOR          @Put CURSOR on current VALUE
  170.           END
  171.         END
  172.         IF '
  173. KEYPRESS==35'                @Down arrow -- the logic is almost the same
  174.         THEN PICT            @     as the Up arrow, so I won't comment
  175. # 0d POSR R\->B 2              @     step by step.  REMEMBER ABOUT THE
  176. \->LIST CURSOR GXOR            @     CONVERSION FROM :TAG:VALUE to TAG:VALUE!!!
  177.           IF 'CURR
  178. ==MAX'
  179.           THEN 1
  180. 'CURR' STO 1 'TOPR'
  181. STO 9 'POSR' STO 9
  182. 'TPOSR' STO 0
  183. 'KEYPRESS' STO
  184.           ELSE CURR
  185. 1 + 'CURR' STO POSR
  186. 9 + 'POSR' STO
  187.             IF '
  188. POSR==54'
  189.             THEN
  190.               IF '
  191. TOPR+4\=/MAX'
  192.               THEN
  193. TOPR 1 + 'TOPR' STO
  194. PICT { # 0d # 9d }
  195. PICT { # 0d # 18d }
  196. { # 131d # 53d }
  197. SUB PICT { # 0d
  198. # 45d } M TOPR 4 +
  199. GET DUP SIZE 2 SWAP
  200. SUB 2 \->GROB REPL
  201. REPL
  202.               END
  203. 45 'POSR' STO
  204.             END
  205. PICT # 0d POSR R\->B
  206. 2 \->LIST CURSOR GXOR
  207.           END
  208.         END
  209.       UNTIL '                @Keep on doing all of this until EXIT is pressed
  210. KEYPRESS==16'
  211.       END
  212. ERASE                        @Erase graphics screen
  213. 0 MENU                       @Restore menu that was there before
  214.     \>>                        @           execution began
  215.   \>>
  216. \>>
  217.  
  218.  
  219.  
  220. %%HP: T(3)A(R)F(.);
  221. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  222. @                                                                      @
  223. @  Name:        SCRL.DMO                                               @
  224. @                                                                      @
  225. @  Description: This is a demo program for the program SCRL.    It     @
  226. @                 contains all of the SI prefixes.  This demo shows    @
  227. @                 how the SCRL program can be used internally from     @
  228. @                 other programs to create scrollable menues.  There   @
  229. @                 is also the option of putting the definitions in     @
  230. @                 the MENU program itself making it standalone.  The   @
  231. @                 format of the list should be the following:          @
  232. @                         TITLE  (to be displayed at top line of lcd   @
  233. @                         VALUE1                                       @
  234. @                         VALUE2 (make sure that all entries have the  @
  235. @                          ...    same length so that no stray         @
  236. @                         VALUEn  characters are left over)            @
  237. @                 With a few modifications, the SCRL program can       @
  238. @                 handle many different types of data and perform      @
  239. @                 many different functions.                            @
  240. @                                                                      @
  241. @  Arguments:   NONE                                                   @
  242. @                                                                      @
  243. @  History:     01-OCT-90 -Dave Walton- Original coding.               @
  244. @                                                                      @
  245. @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
  246. \<< {
  247. "     SI Prefixes"      @ TITLE
  248. ":deka:1E1   "          @ VALUE1
  249. ":hecto:1E2  "          @ VALUE2, etc.
  250. ":kilo:1E3   "
  251. ":mega:1E6   "
  252. ":giga:1E9   "
  253. ":tera:1E12  "
  254. ":peta:1E15  "
  255. ":exa:1E18   "
  256. ":deci:1E-1  "
  257. ":centi:1E-2 "
  258. ":milli:1E-3 "
  259. ":micro:1E-6 "
  260. ":nano:1E-9  "
  261. ":pico:1E-12 "
  262. ":femto:1E-15"
  263. ":atto:1E-18 " }
  264. SCRL                    @ Invoke MENU program
  265. \>>
  266.  
  267.  
  268.